#pragma once

#include <vector>
#include "DocPoint.h"
using std::vector;

typedef unsigned char ExecutionType;
typedef unsigned char ExecutionProperty;

namespace Execution
{
	extern ExecutionType ERT_NONE;
	extern ExecutionType ERT_ADD;
	extern ExecutionType ERT_ADD_STRING;
	extern ExecutionType ERT_DELETE; 
	extern ExecutionType ERT_NEW_LINE; 
	extern ExecutionType ERT_DEL_LINE; 
	extern ExecutionType ERT_MOVE;

	extern ExecutionProperty ERP_DONE;
	extern ExecutionProperty ERP_MAKING;
}



struct ExecutionRecord
{
	ExecutionType action;
	DocPoint start;
	union {
		wchar_t* str;
		DocPoint* info;
	};
};

class ExecutionHistory
{
public:
	void Add(DocPoint start, wchar_t* str);
	void Add(DocPoint start, wchar_t letter);
	void Delete(DocPoint start, wchar_t* str);
	void Delete(DocPoint start, wchar_t letter);
	void Move(DocPoint from, DocPoint toStart, DocPoint toEnd);

public:
	vector<ExecutionRecord>& GetHistory() { return history; }
	ExecutionHistory();

private:
	vector<ExecutionRecord> history;
	int now;

private:
	void MergeLetters();
};